PYTHONVERSION = 2.7
CC = icpc
#CC = g++
#CFLAGS = -Wall -g -O1 -fopenmp -I/home/kav/local/include -I/usr/include/python$(PYTHONVERSION)
CFLAGS = -Wall -O2 -I/home/kav/local/include -I/usr/include/python$(PYTHONVERSION)
#CFLAGS = -O2 -openmp -I/home/kav/local/include
#CFLAGS = -g -I/home/kav/local/include
LFLAGS = -L/home/kav/local/lib
LIBS = -lz -lgsl -lgslcblas -lpython$(PYTHONVERSION)
OBJ = obj
BINDIR = bin
OUT = vlasov

default: all

$(OBJ)/mymath.o: mymath.h mymath.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c mymath.cpp -o $(OBJ)/mymath.o

$(OBJ)/file_saving.o: file_saving.h file_saving.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c file_saving.cpp -o $(OBJ)/file_saving.o

$(OBJ)/mesh.o: mesh.h mesh.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c mesh.cpp -o $(OBJ)/mesh.o
	
$(OBJ)/fdtd.o: mesh.h fdtd.h fdtd.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c fdtd.cpp -o $(OBJ)/fdtd.o
	
$(OBJ)/pfc.o: pyinput.h mesh.h fdtd.h pfc.h pfc.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c pfc.cpp -o $(OBJ)/pfc.o

$(OBJ)/particle.o: particle.h particle.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c particle.cpp -o $(OBJ)/particle.o
	
$(OBJ)/pyinput.o: pfunc.h pyinput.h pyinput.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c pyinput.cpp -o $(OBJ)/pyinput.o

$(OBJ)/pfunc.o: pfunc.h pfunc.cpp
	$(CC) $(CFLAGS) $(LFLAGS) -c pfunc.cpp -o $(OBJ)/pfunc.o

$(BINDIR)/$(OUT): $(OBJ)/pfunc.o $(OBJ)/pyinput.o $(OBJ)/mymath.o $(OBJ)/file_saving.o $(OBJ)/mesh.o $(OBJ)/fdtd.o $(OBJ)/pfc.o $(OBJ)/particle.o pfc.h mymath.h file_saving.h fdtd.h particle.h solver.h main.cpp
	$(CC) main.cpp -o $(BINDIR)/$(OUT) $(OBJ)/pfunc.o $(OBJ)/pyinput.o $(OBJ)/mymath.o $(OBJ)/file_saving.o $(OBJ)/mesh.o $(OBJ)/fdtd.o $(OBJ)/pfc.o $(OBJ)/particle.o $(CFLAGS) $(LFLAGS) $(LIBS)
	
all: $(OBJ)/pfunc.o $(OBJ)/pyinput.o $(OBJ)/mymath.o $(OBJ)/file_saving.o $(OBJ)/mesh.o $(OBJ)/fdtd.o $(OBJ)/pfc.o $(OBJ)/particle.o $(BINDIR)/$(OUT)

clean:
	rm -f $(OBJ)/*.o $(BINDIR)/$(OUT)
